require 'net/http'
require 'uri'
require 'json'

uri = URI('http://127.0.0.1:3000/learningSpace/register')
puts uri.host, uri.port, uri.path

def happy
  uri = URI('http://127.0.0.1:3000/learningSpace/register')
  partner = {
    :username => [*(0..9),*('a'..'z'),*('A'..'Z')].to_a.shuffle[0..7].join,
    :password =>'ljh200050',
    :initialLevel => rand(1..3),
    :planning => rand(1..4),
    :learnPurpose => rand(1..5),
    :learnStyle => rand(1..3)
  }
  http = Net::HTTP.new(uri.host, uri.port)
  req = Net::HTTP::Post.new(uri.path,'Content-Type' => 'application/json')
  req.body = partner.to_json
  http.request(req)
end

500.times do
  happy
end


# puts [*(0..9),*('a'..'z'),*('A'..'Z')].to_a.shuffle[0..7].join